package com.huike.controller;

import com.huike.core.controller.BaseController;
import com.huike.core.domain.AjaxResult;
import com.huike.dto.ClueRecordDto;
import com.huike.result.MyPageResult;
import com.huike.result.PageResult;
import com.huike.service.ClueRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("clues/record")
@Slf4j
public class ClueRecordController extends BaseController {

    @Autowired
    private ClueRecordService clueRecordService;

    /**
     * 查询线索跟进记录
     * @param
     * @return
     */
    @GetMapping("/list")
    public MyPageResult getClueRecordList(@RequestParam Integer clueId) {
        log.info("查询线索跟进记录，{}",clueId);
        PageResult rows = clueRecordService.getClueRecordList(clueId);
        return MyPageResult.ok(rows.getRecords(),rows.getTotal());
    }

    /**
     * 新增线跟进记录
     * @param clueRecordDto
     * @return
     */
    @PostMapping
    public AjaxResult addClueRecord(@RequestBody ClueRecordDto clueRecordDto ) {
        log.info("新增线跟进记录，{}",clueRecordDto);
        clueRecordService.addClueRecord(clueRecordDto);
        return success();
    }

}
